package com.taikang.hmp.hservice.paper.service.impl;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.taikang.hmp.hbusiness.doctor.selfdiagnosis.bean.HealthTag;
import com.taikang.hmp.hservice.doctor.chineseevalmodel.bean.Hdbzdcchmedicine;
import com.taikang.hmp.hservice.doctor.chineseevalmodel.bean.Hdmdevalresult;
import com.taikang.hmp.hservice.doctor.chineseevalmodel.bean.SolarTermInfo;
import com.taikang.hmp.hservice.doctor.healthrickevalmodel.bean.HypertensionReport;
import com.taikang.hmp.hservice.paper.service.IQuestionnaireService;
import com.taikang.hmp.frame.common.datastructre.Dto;
import com.taikang.hmp.frame.common.datastructre.support.BaseDto;
import com.taikang.hmp.frame.common.datastructre.support.ResponseDto;
import com.taikang.hmp.frame.common.service.impl.BaseServiceImpl;

public class QuestionnaireServiceImpl extends BaseServiceImpl implements
		IQuestionnaireService {
	private static final String HEIGHT = "height";
	private static final String WEIGHT = "weight";
	private static final String SEX = "sex";
	private static final String TNB = "tnb";// 是否得糖尿病
	private static final String GXY = "gxy";// 高血压
	private static final String GXZ = "gxz";// 高血脂
	private static final String TF = "tf";// 痛风
	private static final String OTHER = "other";// 分数

	/**
	 * 实症与虚症的优先算法 实症与虚症比较，返回偏颇体质类型的数组，rtn[0]存储体质类型角标，rtn[1]中0表示虚症，1表示实症
	 * 
	 * @param xz
	 * @param sz
	 * @return
	 */
	public static int[] sxCompare(double[] xz, double[] sz, double[] xzSort,
			double[] szSort) {
		int[] rtn = new int[2];
		Arrays.sort(xzSort);
		Arrays.sort(szSort);
		System.out.println(Arrays.toString(xzSort));
		System.out.println(Arrays.toString(szSort));
		if (xzSort[xzSort.length - 1] >= szSort[szSort.length - 1]) {
			int index = yxTz(xzSort[xzSort.length - 1], xz);
			rtn[0] = index;
			rtn[1] = 0;
		} else {
			int index = yxTz(szSort[szSort.length - 1], sz);
			rtn[0] = index;
			rtn[1] = 1;
		}
		return rtn;
	}

	/**
	 * 实症或者虚证中相同转化分的优先体质算法
	 * 
	 * @param a
	 * @param xz
	 * @return
	 */
	public static int yxTz(double max, double[] xz) {
		int index = 0;
		if (xz[0] == max) {
			index = 0;
		} else if (xz[1] == max) {
			index = 1;
		} else if (xz[2] == max) {
			index = 2;
		} else if (xz[3] == max) {
			index = 3;
		}
		return index;
	}

	/**
	 * 计算每种体质的转化分数
	 * 
	 * @param questionsStr
	 * @param scores
	 * @param constitutionsStr
	 * @return
	 */
	public static double[] countScore(String[] scores, String constitutionsStr) {

		int[] constitutionsScore = new int[9];
		int[] constitutionNum = new int[9];
		double[] countScore = new double[9];
		String[] constitutions = constitutionsStr.split(",");
		for (int i = 0; i < constitutions.length; i++) {
			if ("1".equals(constitutions[i])) {
				constitutionsScore[0] = constitutionsScore[0]
						+ Integer.valueOf(scores[i]);
				constitutionNum[0]++;
			} else if ("2".equals(constitutions[i])) {
				constitutionsScore[1] = constitutionsScore[1]
						+ Integer.valueOf(scores[i]);
				constitutionNum[1]++;
			} else if ("3".equals(constitutions[i])) {
				constitutionsScore[2] = constitutionsScore[2]
						+ Integer.valueOf(scores[i]);
				constitutionNum[2]++;
			} else if ("4".equals(constitutions[i])) {
				constitutionsScore[3] = constitutionsScore[3]
						+ Integer.valueOf(scores[i]);
				constitutionNum[3]++;
			} else if ("5".equals(constitutions[i])) {
				constitutionsScore[4] = constitutionsScore[4]
						+ Integer.valueOf(scores[i]);
				constitutionNum[4]++;
			} else if ("6".equals(constitutions[i])) {
				constitutionsScore[5] = constitutionsScore[5]
						+ Integer.valueOf(scores[i]);
				constitutionNum[5]++;
			} else if ("7".equals(constitutions[i])) {
				constitutionsScore[6] = constitutionsScore[6]
						+ Integer.valueOf(scores[i]);
				constitutionNum[6]++;
			} else if ("8".equals(constitutions[i])) {
				constitutionsScore[7] = constitutionsScore[7]
						+ Integer.valueOf(scores[i]);
				constitutionNum[7]++;
			} else {
				constitutionsScore[8] = constitutionsScore[8]
						+ Integer.valueOf(scores[i]);
				constitutionNum[8]++;
			}
		}
		for (int j = 0; j < countScore.length; j++) {
			countScore[j] = ((constitutionsScore[j] - constitutionNum[j]) / (constitutionNum[j] * 4.0)) * 100;
		}
		return countScore;
	}

	@Override
	public List<Dto> getQuestion(String id) {

		List<Object> resultList = super.getNewDao().queryForList(
				"questionnaire_space.getQuestion", id);
		List<Dto> result = new ArrayList<Dto>();
		for (int i = 0; i < resultList.size(); i++) {
			Map map = (Map) resultList.get(i);
			Dto resultMap = new BaseDto();
			resultMap.put("detailid", map.get("detail_id").toString());
			resultMap.put("detailname", map.get("detail_name").toString());
			resultMap.put("questionid", map.get("question_id").toString());
			resultMap.put("questionname", map.get("question_name").toString());
			resultMap.put("questionvalue", map.get("question_value").toString()
					.replaceAll("\"", "'"));
			resultMap.put("sex", map.get("sex").toString());
			resultMap.put("bz", map.get("bz").toString());
			result.add(resultMap);
		}
		return result;

	}

	@Override
	public List<Dto> saveQuestionrResult(Dto dto) {
		String templateId = dto.getAsString("templateid");
		String datetime = date("yyyy-MM-dd HH:mm:ss");
		Dto result = new BaseDto();
		String url = "";
		if ("1".equals(templateId)) {
			// 中医体质
			result.put("Evalname", "中医体质评估");
		} else if ("2".equals(templateId)) {
			// 健康风险评估
			result.put("Evalname", "健康风险评估");
			url = "/html/paper/HealthReport.html?type="
					+ templateId + "&uid="+dto.getAsString("uid");
		}
		result.put("Evalid", java.util.UUID.randomUUID().toString());
		result.put("Customid", dto.getAsString("customerid"));
		result.put("Taginfo", "1");
		result.put("Evalstate", "1");
		result.put("Evaldate", datetime);
		result.put("Evalinfo", url);
		result.put("PaperResult", dto.getAsString("requestlist"));
		result.put("Sourcecd", dto.getAsString("requestsource"));
		result.put("Operater", dto.getAsString("uid"));
		result.put("Operatedate", new Date());
		result.put("templateId", templateId);
		
		super.getNewDao().insert("questionnaire_space.saveQuestionrResult",
				result);

		// 回现到页面数据
		Dto resultMap = new BaseDto();
		List<Dto> results = new ArrayList<Dto>();
		resultMap.put("url", url);
		results.add(resultMap);
		return results;
	}

	public String date(String pat) {

		SimpleDateFormat format = new SimpleDateFormat(pat);
		return format.format(new Date());
	}

	public String returnMap(int key) {
		Map<Integer, String> map = new HashMap<Integer, String>();
		// 阳虚 阴虚 气虚 痰湿 湿热 血瘀 特稟 气郁 平和
		map.put(1, "阳虚质");
		map.put(2, "阴虚质");
		map.put(3, "气虚质");
		map.put(4, "痰湿质");
		map.put(5, "湿热质");
		map.put(6, "血瘀质");
		map.put(7, "特稟质");
		map.put(8, "气郁质");
		map.put(9, "平和质");
		return map.get(key);

	}

	public String showURL(int type, int index) {

		String yang = "/zytzpg/yang.html?index=" + index;
		String yinxu = "/zytzpg/yinxu.html?index=" + index;
		String qixu = "/zytzpg/qixu.html?index=" + index;
		String tan = "/zytzpg/tan.html?index=" + index;
		String shi = "/zytzpg/shi.html?index=" + index;
		String xueyu = "/zytzpg/xueyu.html?index=" + index;
		String te = "/zytzpg/te.html?index=" + index;
		String qiyu = "/zytzpg/qiyu.html?index=" + index;
		String pinghe = "/zytzpg/pinghe.html?index=" + index;
		String url = type == 1 ? yang : (type == 2 ? yinxu : (type == 3 ? qixu
				: (type == 4 ? tan : (type == 5 ? shi : (type == 6 ? xueyu
						: (type == 7 ? te : (type == 8 ? qiyu : pinghe)))))));

		return url;
	}

	@Override
	public List<Dto> getQuestionrResult(Dto paramDto) {
		String type = paramDto.getAsString("type");
		List<Dto> list = super.getNewDao().queryForList(
				"questionnaire_space.getQuestionrResult", paramDto);
		String paperResult = null;
		Dto resultDto = new BaseDto();
		if (list.size() > 0) {
			// 问卷结果
			paperResult = list.get(0).getAsString("PAPER_RESULT");
		}
		// 健康风险评估
		if ("2".equals(type)) {

			Dto dto = new BaseDto();
			dto.put("evalId", list.get(0).getAsString("EVAL_ID"));
			List<Dto> detilList = super.getNewDao().queryForList(
					"questionnaire_space.getQuestion", type);// questionid+detilname
			Map<String, String> datilMap = new HashMap<String, String>();
			for (int i = 0; i < detilList.size(); i++) {
				datilMap.put(detilList.get(i).getAsString("QUESTION_ID"),
						detilList.get(i).getAsString("DETAIL_NAME"));
			}
			JSONArray jaResult = JSONArray.fromObject(paperResult);
			int thirdScore = 0;
			String scores[] = new String[25];
			int j = 0;
			for (int i = 0; i < jaResult.size(); i++) {
				JSONObject joResult = (JSONObject) jaResult.get(i);
				String questionId = (String) datilMap.get(joResult
						.get("questionid"));
				// 性别
				if (SEX.equals(questionId)) {
					dto.put("sex", joResult.getString("score"));
				}// 身高
				else if (HEIGHT.equals(questionId)) {
					dto.put("height", joResult.getString("score"));
				}// 体重
				else if (WEIGHT.equals(questionId)) {
					dto.put("weight", joResult.getString("score"));
				}
				// 糖尿病
				else if (TNB.equals(questionId)) {
					dto.put("tnb", getScore(joResult.getString("score")));
				}// 高血压
				else if (GXY.equals(questionId)) {
					dto.put("gxy", getScore(joResult.getString("score")));
				}// 高血脂
				else if (GXZ.equals(questionId)) {
					dto.put("gxz", getScore(joResult.getString("score")));
				}// 痛风
				else if (TF.equals(questionId)) {
					dto.put("tf", getScore(joResult.getString("score")));
				} else {
					thirdScore += joResult.getInt("score");
					
					int optionScore = joResult.getInt("score");
					if (optionScore==1) {
						scores[j] = j + 3 + ":A";
					} else if (optionScore==3) {
						scores[j] = j + 3 + ":B";
					} else if (optionScore==5) {
						scores[j] = j + 3 + ":C";
					}
					j++;
				}
			}
			// HypertensionReport domain = assessService.querybc(paramDto);

			String sex = dto.getAsString("sex"); // 性别

			int dm = dto.getAsInteger("tnb"); // 糖尿病
			int hypertension = dto.getAsInteger("gxy"); // 高血压
			int gxz = dto.getAsInteger("gxz"); //
			// 高血脂
			int tf = dto.getAsInteger("tf"); // 痛风

			double bmi = Math
					.round(Double.parseDouble(dto.getAsString("weight"))
							/ Math.pow(Double.parseDouble(dto
									.getAsString("height")) / 100, 2) * 10) / 10.0;
			// String scoreMap = domain.getScore();
			// String scores[] = scoreMap.split(",");

			int score = 0; // 得分
			String miaoshu = ""; // 描述

			// 第2题任何一个选A，直接得分，不计算，并获取相应描述
			if (dm == 0 && hypertension != 0 && gxz != 0 && tf != 0) {
				score = 45;
				miaoshu = getMs(1);
			} else if (hypertension == 0 && dm != 0 && gxz != 0 && tf != 0) {
				score = 45;
				miaoshu = getMs(2);
			} else if (gxz == 0 && hypertension != 0 && dm != 0 && tf != 0) {
				score = 45;
				miaoshu = getMs(3);
			} else if (tf == 0 && hypertension != 0 && gxz != 0 && dm != 0) {
				score = 45;
				miaoshu = getMs(4);
			} else if (dm == 0 && hypertension == 0 && gxz != 0 && tf != 0) {
				score = 35;
				miaoshu = getMs(5);
			} else if (dm == 0 && gxz == 0 && hypertension != 0 && tf != 0) {
				score = 35;
				miaoshu = getMs(6);
			} else if (dm == 0 && tf == 0 && hypertension != 0 && gxz != 0) {
				score = 35;
				miaoshu = getMs(7);
			} else if (dm != 0 && tf != 0 && hypertension == 0 && gxz == 0) {
				score = 35;
				miaoshu = getMs(8);
			} else if (dm != 0 && gxz != 0 && hypertension == 0 && tf == 0) {
				score = 35;
				miaoshu = getMs(9);
			} else if (dm != 0 && hypertension != 0 && tf == 0 && gxz == 0) {
				score = 35;
				miaoshu = getMs(10);
			} else if (dm == 0 && hypertension == 0 && tf != 0 && gxz == 0) {
				score = 25;
				miaoshu = getMs(11);
			} else if (dm == 0 && hypertension == 0 && tf == 0 && gxz != 0) {
				score = 25;
				miaoshu = getMs(12);
			} else if (dm == 0 && hypertension != 0 && tf == 0 && gxz == 0) {
				score = 25;
				miaoshu = getMs(13);
			} else if (dm != 0 && hypertension == 0 && tf == 0 && gxz == 0) {
				score = 25;
				miaoshu = getMs(14);
			} else if (dm == 0 && hypertension == 0 && tf == 0 && gxz == 0) {
				score = 20;
				miaoshu = getMs(15);
			} else { // 只有第2题没有选A时，才会进入计分 score = 0;

				// 第1题计分规则
				if (bmi >= 28) {
					score += 1;
				} else if (bmi >= 24 && bmi < 28) {
					score += 3;
				} else if (bmi >= 18.5 && bmi < 24) {
					score += 5;
				} else {
					score += 3;
				}

				// 第2题计分规则
				if (dm == 2 && hypertension == 2 && tf == 2 && gxz == 2) {
					score += 1;
				} else if (dm == 1 && hypertension == 1 && tf == 1 && gxz == 1) {
					score += 5;
				} else {
					score += 3;
				}
				score += thirdScore;
				// 第3-20题计分规则
				/*
				 * for (int i = 0; i < scores.length; i++) { if
				 * (scores[i].split(":")[1].equals("A")) { score += 1; } else if
				 * (scores[i].split(":")[1].equals("B")) { score += 3; } else {
				 * score += 5; } }
				 */

				if (score >= 20 && score <= 52) {
					miaoshu = getMs(16);
				} else if (score >= 53 && score <= 79) {
					miaoshu = getMs(17);
				} else if (score >= 80 && score <= 100) {
					miaoshu = getMs(18);
				}
			}

			List<HealthTag> jkjd = new ArrayList<HealthTag>(); // 健康标签
			String risks = ""; // 健康风险 // 若健康评估标签为空，则得到标签列表；否则使用已有的标签列表
			// if (domain.getTags() == null || "".equals(domain.getTags())) {
			HealthTag tagbmi = new HealthTag();
			if (bmi >= 28) {
				risks += "肥胖@";
				tagbmi.setHealthtag("肥胖");
				tagbmi.setHealthresult("你太胖了，已经严重影响到健康哦");
			} else if (bmi >= 24 && bmi < 28) {
				risks += "超重@";
				tagbmi.setHealthtag("超重");
				tagbmi.setHealthresult("超重是肥胖的前奏，离肥胖已经只有一步之遥了");
			} else if (bmi >= 18.5 && bmi < 24) {
				tagbmi.setHealthtag("身材匀称");
				tagbmi.setHealthresult("体重适宜，继续保持");
			} else {
				risks += "体重过低@";
				tagbmi.setHealthtag("骨感");
				tagbmi.setHealthresult("体重太轻，会对身体没有保护作用，适当要增加些肉肉的");
			}
			jkjd.add(tagbmi);

			Random rand = new Random();
			Map<String, Object> map = new HashMap<String, Object>();
			for (int value : getRandomMap().values()) {
				map.put("question", scores[value].split(":")[0]);
				map.put("options", scores[value].split(":")[1]);
				List<HealthTag> sdf = super.getNewDao().queryForList(
						"assess_space.getbq", map);
				HealthTag tag = sdf.get(0);
				tag.setHealthtag(tag.getHealthtag().split("/")[rand.nextInt(2)]);
				jkjd.add(tag);
			}
			dto.put("tags", turnTagListToString(jkjd));
			super.getNewDao().insert("questionnaire_space.saveyjkbq", dto);
			// System.out.println("Tags save " + result + "!");
			// } else {
			// jkjd = turnStringToTagList(domain.getTags());
			// }

			for (int i = 0; i < 17; i++) {
				int q = Integer.parseInt(scores[i].split(":")[0]);
				if (q == 4) {
					if (scores[i].split(":")[1].equals("A")) {
						risks += "熬夜、睡眠不足@";
					}
					if (scores[i].split(":")[1].equals("B")) {
						risks += "睡眠不规律@";
					}
				}
				if (q == 5) {
					if (scores[i].split(":")[1].equals("A")) {
						risks += "抽烟@";
					}
					if (scores[i].split(":")[1].equals("B")) {
						risks += "抽烟@";
					}
				}
				if (q == 6) {
					if (scores[i].split(":")[1].equals("A")) {
						risks += "油烟吸入多@";
					}
				}
				if (q == 7) {
					if (scores[i].split(":")[1].equals("A")) {
						risks += "喝水少@";
					}
				}
				if (q == 8) {
					if (scores[i].split(":")[1].equals("A")) {
						risks += "饮酒过量@";
					}
				}
				if (q == 9) {
					if (scores[i].split(":")[1].equals("A")) {
						risks += "主食量偏大@";
					}
					if (scores[i].split(":")[1].equals("B")) {
						risks += "不吃主食@";
					}
				}
				if (q == 10) {
					if (scores[i].split(":")[1].equals("A")) {
						risks += "不吃蔬菜、水果@";
					}
					if (scores[i].split(":")[1].equals("B")) {
						risks += "蔬菜、水果摄入不足@";
					}
				}
				if (q == 11) {
					if (scores[i].split(":")[1].equals("A")) {
						risks += "肉类摄入过多@";
					}
					if (scores[i].split(":")[1].equals("B")) {
						risks += "不吃荤类肉食@";
					}
				}
				if (q == 12) {
					if (scores[i].split(":")[1].equals("A")) {
						risks += "不吃海鲜产品@";
					}
					if (scores[i].split(":")[1].equals("B")) {
						risks += "海鲜产品摄入过多@";
					}
				}
				if (q == 13) {
					if (scores[i].split(":")[1].equals("A")) {
						risks += "无运动@";
					}
					if (scores[i].split(":")[1].equals("B")) {
						risks += "运动不足@";
					}
				}
				if (q == 14) {
					if (scores[i].split(":")[1].equals("A")) {
						risks += "有缺钙倾向@";
					}
				}
				if (q == 15) {
					if (scores[i].split(":")[1].equals("A")) {
						risks += "肠胃功能紊乱@";
					}
				}
			}

			resultDto.put("sex", sex);
			resultDto.put("score", score);
			if (risks.length() > 0) {
				resultDto.put("risks", risks.substring(0, risks.length() - 1));
			} else {
				resultDto.put("risks", "");
			}
			resultDto.put("miaoshu", miaoshu);
			resultDto.put("list", jkjd);
		}

		List<Dto> results = new ArrayList<Dto>();
		results.add(resultDto);
		return results;
	}

	@Override
	public Hdbzdcchmedicine getJqys(Dto paramDto) {

		String index = paramDto.getAsString("index");
		String sz[] = { "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏",
				"小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露",
				"霜降", "立冬", "小雪", "大雪", "冬至" };
		String tz = paramDto.getAsString("tz");
		String jq = sz[Integer.valueOf(index)];
		String tzName = returnMap(Integer.valueOf(tz));
		Dto map = new BaseDto();
		map.put("solor_term", jq);
		map.put("tcm_constitution", tzName);

		List<Hdbzdcchmedicine> list = super.getNewDao().queryForList(
				"questionnaire_space.getJqys", map);
		return list.get(0);
	}

	@Override
	public Dto getCorporeitySolar(Dto paramDto) {
		Hdmdevalresult result = (Hdmdevalresult) super.getNewDao()
				.queryForObject("questionnaire_space.getCorporeitySolar",
						paramDto.getAsString("customerid"));
		Dto resultMap = new BaseDto();
		if (result != null) {
			SolarTermInfo info = new SolarTermInfo();
			String solar = info.getSoralTerms();
			String evalinfo = result.getEvalinfo();
			resultMap.put("solar", solar);
			if (evalinfo.contains("yang")) {
				resultMap.put("corporeity", "阳虚质");
			} else if (evalinfo.contains("yinxu")) {
				resultMap.put("corporeity", "阴虚质");
			} else if (evalinfo.contains("qixu")) {
				resultMap.put("corporeity", "气虚质");
			} else if (evalinfo.contains("tan")) {
				resultMap.put("corporeity", "痰湿质");
			} else if (evalinfo.contains("shi")) {
				resultMap.put("corporeity", "湿热质");
			} else if (evalinfo.contains("xueyu")) {
				resultMap.put("corporeity", "血瘀质");
			} else if (evalinfo.contains("te")) {
				resultMap.put("corporeity", "特稟质");
			} else if (evalinfo.contains("qiyu")) {
				resultMap.put("corporeity", "气郁质");
			} else if (evalinfo.contains("pinghe")) {
				resultMap.put("corporeity", "平和质");
			}
		}
		return resultMap;
	}

	public List<HealthTag> turnStringToTagList(String tags) {
		List<HealthTag> tagList = new ArrayList<HealthTag>();
		String[] tagArray = tags.split("@");
		for (int i = 0; i < tagArray.length; i++) {
			String[] tagTemp = tagArray[i].split("&");
			HealthTag tag = new HealthTag();
			for (int n = 0; n < tagTemp.length; n++) {
				tag.setHealthtagid(tagTemp[0]);
				tag.setQuestion(tagTemp[1]);
				tag.setOptions(tagTemp[2]);
				tag.setHealthtag(tagTemp[3]);
				tag.setHealthresult(tagTemp[4]);
			}
			tagList.add(tag);
		}
		return tagList;
	}

	public String getMs(int i) {
		Map<Integer, String> map = new HashMap<Integer, String>();
		map.put(1, "危险，代谢疾病来袭！@亲，你血糖有异常，健康红灯亮起啦！从现在开始，控制血糖，享受甜蜜蜜的人生哦。");
		map.put(2, "危险，代谢疾病来袭！@亲，你步入了高血压行列，听，警报拉响啦！珍爱生命，从现在开始，要控制血压哦。");
		map.put(3, "危险，代谢疾病来袭！@亲，你已经高血脂啦，血脂过多，容易造成“血稠”哦！清洁血管从现在开始，健康的血管，健康的生活！");
		map.put(4, "危险，代谢疾病来袭！@痛风（血尿酸高）找到咱家了呀！亲，会关节疼的哦！拒绝关节疼，降低血尿酸，从现在开始！");
		map.put(5, "危险，代谢疾病来袭！@亲，糖尿病合并高血压，两种慢性病啦！从现在开始，控制血糖、血压的同时，享受甜蜜蜜的人生！");
		map.put(6, "危险，代谢疾病来袭！@糖尿病合并高血脂，亲，两种慢性病啦！清洁血管的糖和血脂，从现在开始，健康的血管，健康的生活！");
		map.put(7, "危险，代谢疾病来袭！@糖尿病合并痛风（血尿酸高），亲，要引起注意啦！控制血糖、降低血尿酸，从现在开始！");
		map.put(8, "危险，代谢疾病来袭！@亲，你有高血压、高血脂两种慢性病，危险哦！控制血压，清洁血管的血脂，健康生活从现在开始！");
		map.put(9,
				"危险，代谢疾病来袭！@亲，两种慢性病高血压和痛风（血尿酸高）都找咱家啦！从现在开始，健康的生活，努力控制血压和血尿酸！");
		map.put(10, "危险，代谢疾病来袭！@亲，你有高血脂、痛风（血尿酸高）两种慢性病，危险哦！现在开始，控制血压的同时要控制血尿酸哦！");
		map.put(11, "危险，代谢疾病来袭！@亲，糖尿病、高血压、高血脂，三高啦！远离三高，拥有健康，从现在开始，控制血糖、血压和血脂！");
		map.put(12,
				"危险，代谢疾病来袭！@糖尿病、高血压、痛风/高血尿酸三种疾病，亲，让偶说啥好呢？赶紧的开始控糖、控压、控血尿酸，拒绝并发症，提高生活质量！");
		map.put(13,
				"危险，代谢疾病来袭！@亲啊，你有糖尿病、高血脂、痛风/高血尿酸，危险啊！控制血糖、血脂、血尿酸，现在势在必行啊，行动起来吧！偶看好你哦！");
		map.put(14,
				"危险，代谢疾病来袭！@亲，又是高血压、又是高血脂、又是尿酸高的，三种疾病！为了能以后的生活更美好，积极治疗疾病，预防并发症，从此刻开始！");
		map.put(15,
				"危险，代谢疾病来袭！@糖尿病、高血压、高血脂、痛风/高血尿酸，四种疾病同时有，亲，健康状况堪忧啊！从现在开始，积极控制疾病、预防并发症，迎接未来美好生活！");
		map.put(16,
				"小心，健康灰色状态！@亲，你目前的健康状态有些糟糕，请高度重视哦。请尽快调整生活方式，如有不适症状立即寻求医生的专业帮助。");
		map.put(17, "注意，健康受到威胁！@亲，你的健康状况勉勉强强。珍爱生命，及时调整生活方式，关注自己的健康！");
		map.put(18, "身体棒棒哒！@亲，您的健康状况良好，请继续保持哦！");
		return map.get(i).toString();
	}

	public String turnTagListToString(List<HealthTag> jkjd) {
		String tags = "";
		for (HealthTag tag : jkjd) {
			String temp = tag.getHealthtagid() + "&";
			temp += tag.getQuestion() + "&";
			temp += tag.getOptions() + "&";
			temp += tag.getHealthtag() + "&";
			temp += tag.getHealthresult();
			tags += temp + "@";
		}
		tags = tags.substring(0, tags.length() - 1);
		return tags;
	}

	public String getScore(String option) {
		String tags = "";
		if ("A".equals(option)) {
			return "0";
		} else if ("B".equals(option)) {
			return "1";
		} else if ("C".equals(option)) {
			return "2";
		}
		return tags;
	}

	public Map<Integer, Integer> getRandomMap() {

		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		Random rand = new Random();
		int x;
		for (int i = 0; map.size() < 10; i++) {
			x = rand.nextInt(17);
			if (!map.containsValue(x)) {
				map.put(i, x);
			}
		}
		return map;
	}
}
